<?php
/**
 * @file views-view-table.tpl.php
 * Template to display a view as a table.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $header: An array of header labels keyed by field id.
 * - $fields: An array of CSS IDs to use for each field id.
 * - $class: A class or classes to apply to the table, based on settings.
 * - $row_classes: An array of classes to apply to each row, indexed by row
 *   number. This matches the index in $rows.
 * - $rows: An array of row items. Each row is an array of content.
 *   $rows are keyed by row number, fields within rows are keyed by field ID.
 * @ingroup views_templates
 */
?>
<?php foreach ($user->roles as $xd_user): ?>
  <?php $user_role_authenticated = $xd_user ?>
  <?php break ?>
<?php endforeach; ?>
<table class="<?php print $class; ?>"<?php print $attributes; ?>>
  <?php if (!empty($title)) : ?>
    <caption><?php print $title; ?></caption>
  <?php endif; ?>
  <thead>
    <tr>
      <?php foreach ($header as $field => $label): ?>
        <th class="views-field views-field-<?php print $fields[$field]; ?>">
          <?php print $label; ?>
        </th>
      <?php endforeach; ?>
    </tr>
  </thead>
  <tbody>
    <?php foreach ($rows as $count => $row): ?>
      <tr class="<?php print implode(' ', $row_classes[$count]); ?>">
        <?php $body_product = "" ?>
        <?php foreach ($row as $field => $content): ?>
            <?php if (preg_match('@body@', $field)): ?>
                <?php $body_product = $content ?>
            <?php endif; ?>
        <?php endforeach; ?>
        <?php foreach ($row as $field => $content): ?>
          <?php if (!preg_match('@body@', $field)): ?>
            <td class="views-field views-field-<?php print $fields[$field]; ?>">
              <?php if (preg_match('@title@', $field)): ?>
                <?php if (!preg_match('@authenticated@', @$user_role_authenticated)): ?>
                  <?php $content = strip_tags($content) ?>
                  <?php $content = "<div class='title'>".$content."</div>" ?>
                <?php endif; ?>
                <?php print $content.$body_product ?>
              <?php else: ?>
                <?php print $content; ?>
              <?php endif ?>
            </td>
          <?php endif ?>
        <?php endforeach; ?>
      </tr>
    <?php endforeach; ?>
  </tbody>
</table>
